<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #box
        {
            width: 100px;
            height: 100px;
            background: #0ff;
            border-top: 5px solid #f00;
            border-right: 5px solid #0f0;
            animation: rotateP 5s infinite ease-in-out;
        }
        @keyframes rotateP
        {
            0%
            {
               transform: rotateX(0) rotateY(0);
            }
            50%
            {
                transform: rotateX(180deg) rotateY(180deg);
            }
            100%
            {
                transform: rotateX(0) rotateY(0)
            }
        }
    </style>
</head>
<body>
    <div id="box"></div>
</body>
</html>